﻿using Microsoft.AspNetCore.Mvc;
using NP.BPMReportPlatform.Entities.BPM_Business;
using NP.BPMReportPlatform.TaxManage.Dto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.ObjectMapping;

namespace NP.BPMReportPlatform.TaxManage
{
    /// <summary>
    /// 税务平台的开票内容查询
    /// </summary>
    // [Authorize]
    [ApiController]
    [Route("api/TaxManage/")]
    public class TaxApplyContentController : BPMReportPlatformController
    {
        private ITaxApplyContentService _taxApplyContentService;
        public TaxApplyContentController(ITaxApplyContentService taxApplyContentService)
        {

            _taxApplyContentService = taxApplyContentService;
        }
        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("TaxApplyContent/EditAsync")]
        public async Task<string> EditAsync([FromBody] TaxApplyContentDto input)
        {
            var mapperResult = ObjectMapper.Map<TaxApplyContentDto, TaxApplyContent>(input);

            var result = "成功";
            try
            {
                await _taxApplyContentService.EditAsync(mapperResult);
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }
            return result;
           
        }

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("TaxApplyContent/QueryAsync")]
        public async Task<PagedResultDto<TaxApplyContentDto>> GetAllAsync([FromBody] TaxApplyContentSearchDto input)
        {

            return await _taxApplyContentService.GetAllAsync(input);
        }

        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("TaxApplyContent/InsertAsync")]
        public async Task<string> SaveAsync([FromBody] TaxApplyContentDto input)
        {
            var mapperResult = ObjectMapper.Map<TaxApplyContentDto, TaxApplyContent>(input);
            var result = "成功";
            try
            { 
                await _taxApplyContentService.SaveAsync(mapperResult);
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }
            return result;
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpDelete]
        [Route("TaxApplyContent/DeleteAsync")]
        public async Task DeleteAsync([FromQuery] Guid id)
        {
            await _taxApplyContentService.DeleteAsync(id);

        }

    }
}
